package hu.elte.tudaskezelo.dbpedialike.views.overlay;

import hu.elte.tudaskezelo.dbpedialike.domain.LocalPOI;
import hu.elte.tudaskezelo.dbpedialike.ws.SPARQLQuery;

import java.util.ArrayList;
import java.util.List;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.ItemizedOverlay;
import org.osmdroid.views.overlay.OverlayItem;

import android.content.Context;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class OverlayFactory {

	final String tag = "OverlayFactory";

	@Inject
	public SPARQLQuery sparqlQuery;

	public ItemizedOverlay<OverlayItem> getLocal(final Context context,
			double longitude, double latitude, double radius, String filter) {

		List<LocalPOI> gatherLocalPOI = sparqlQuery.gatherLocalPOI(longitude,
				latitude, radius, filter);
		List<OverlayItem> plist = new ArrayList<OverlayItem>();

		for (LocalPOI localPOI : gatherLocalPOI) {
			plist.add(new OwnOverlayItem(context, localPOI.getType(), localPOI
					.getName(), localPOI.getName(), localPOI.getDescription(),
					new GeoPoint(localPOI.getLatitude(),localPOI.getLongitude())));
		}
	
		ItemizedOverlay<OverlayItem> result = new ItemizedIconOverlay<OverlayItem>(
				context, plist, new ItemGesture(context));

		return result;
	}
}
